The SampleStorageClassDriver folder contains sample code for a USB mass storage class driver. It consists of a native unit table driver and a USB mass storage class driver. This sample code is based on the actual Apple Mass Storage class driver 2.0.4 code which was included as part of the Mac OS 9 Update.
Description
The SampleStorageClassDriver sample demonstrates the use of the Mac OS USB to create a driver for a mass storage class device. The sample demonstrates support for USB Mass Storage Devices which conform to the USB Mass Storage specification with some exceptions.
subclass 6 - SCSI Transparent command set devices.
- Support for USB Mass Storage protocols
protocol 0 - Command/Bulk/Interrupt protocol
protocol 1 - Command/Bulk protocol
protocol 80 - Bulk Only protocol
- Support for Standard HFS, Extended HFS and DOS volumes.
- Support for single and multiple partitioned disks
- Handling of auto and manual eject devices
- support UDF on compatible media (media with 2048 byte blocks such as 640MB Magneto-Optical cartridges).
Exceptions -
The USB Mass Storage components do not support
subclass 2 - SFF-8020i Compliant CD-ROM devices,
subclass 3 - QIC-157 compliant tape devices
Building the Code
This sample was built using the Metrowerks CodeWarrior Pro 4, IDE version 3.2 environment and Mac OS USB DDK version 1.4.1f4. Also required are Universal Interfaces and Libraries 3.3. Later versions of these tools can also be used: consult the Mac OS USB DDK Readme file to determine which version of Universal Interfaces and Libraries to use. This driver is designed to be compatible with Mac OS USB releases back to version 1.3.5.
This sample class driver is based on the actual mass storage class driver that Apple ships with the Mac OS 9.0 Update. The code has been modified to require that you specify a Vendor and Product ID, along with the mass storage class subclass setting.
To accomplish this, open the StorageDeviceConfiguration.h header file and specify the kDriverVendorID, the kDriverProductID, and the kDriverSubclassID values to match your device. If your device is a composite class device with a mass storage class interface, also set the kUSBInterfaceMatchOnly bit in the driver loading options field.
To rebuild the project, place the USBSampleStorageDriver folder into the USBDDK:Examples: folder. The CodeWarrior project file assumes certain project-specific access paths. The resulting class driver, SampleStorageDriver, is built into the USBDDK:Extensions-MCWBuilt: folder.
Changes from the previous release of the SampleStorageClassDriver sample
1. The source code in this project is a complete rewrite of the sample provided in previous versions of the DDK. This sample supports additional protocols over the original sample.
2. The sample demonstrates data blocking and blocking for media which implements block sizes greater than 512 bytes - like CD-ROM's which use a 2K block size.
3. The sample provides better support for hot unplugged devices and media.
Using the CodeWarrior project file
The supplied Metrowerks CodeWarrior (CW) Project file was created using CW Pro 4, IDE 3.2. If you use a different version of CW Pro, you will have to convert the project file. If you have problems with the resulting driver, check the following:
0. Ensure that the folder for this sample is present in the ":Examples:" folder of the DDK so that dependent libraries can be found for the project.
1. Ensure that you are using the Universal Interfaces and Libraries v3.3. These files are available from the Apple Developer Connections web page using the following URL:
http://developer.apple.com/sdk/index.html
2. Check the Project Preferences, C/C++ Language Preference Panel and check that there is no Prefix File specified. This project was created to not use precompiled headers. There is no problem with using precompiled headers so long as they match the version of Universal Interfaces and Libraries, which you are using.
Bug Reports
If you find any bugs, please send them to "usb@isg.apple.com" and Developer Technical Support staff will try to address them.
Questions
For any questions which you may have with this sample or with Mac OS USB, please submit them to either the Mac OS USB Developer mailing list, usb@isg.apple.com, or to Apple Worldwide Developer Technical Support (WWDTS), dts@apple.com. If you are not familiar with the WWDTS support plans, please check them out at the Developer Programs web page,
<http://developer.apple.com/programs/>.
To subscribe to the Mac OS USB Developer mailing list, send an email to usb@isg.apple.com with the subject set to "subscribe".
Licensing
Disclaimer:
IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
("Apple") in consideration of your agreement to the following terms, and your
use, installation, modification or redistribution of this Apple software
constitutes acceptance of these terms. If you do not agree with these terms,
please do not use, install, modify or redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and subject
to these terms, Apple grants you a personal, non-exclusive license, under Appleās
copyrights in this original Apple software (the "Apple Software"), to use,
reproduce, modify and redistribute the Apple Software, with or without
modifications, in source and/or binary forms; provided that if you redistribute
the Apple Software in its entirety and without modifications, you must retain
this notice and the following text and disclaimers in all such redistributions of
the Apple Software. Neither the name, trademarks, service marks or logos of
Apple Computer, Inc. may be used to endorse or promote products derived from the
Apple Software without specific prior written permission from Apple. Except as
expressly stated in this notice, no other rights or licenses, express or implied,
are granted by Apple herein, including but not limited to any patent rights that
may be infringed by your derivative works or by other works in which the Apple
Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN